package com.zhanjixun.weixin.utils;

import com.zhanjixun.weixin.domain.Card;
import com.zhanjixun.weixin.domain.LocationMsg;
import com.zhanjixun.weixin.domain.RevokeMsg;
import com.zhanjixun.weixin.domain.Sticker;
import org.apache.commons.lang3.StringEscapeUtils;

/**
 * contentTools
 *
 * @author :zhanjixun
 * @date : 2018/11/19 14:13
 */
public class ContentTools {

    /**
     * 内容xml转换为动画表情
     *
     * @param content
     * @return
     */
    public static Sticker toSticker(String content) {
        return Sticker.valueOf(StringEscapeUtils.unescapeHtml4(content).replace("<br/>", "").replace("\t", ""));
    }

    /**
     * 撤回消息
     *
     * @param content
     * @return
     */
    public static RevokeMsg toRevokeMsg(String content) {
        return RevokeMsg.valueOf(StringEscapeUtils.unescapeHtml4(content).replace("<br/>", "").replace("\t", ""));
    }

    /**
     * 位置消息
     *
     * @param oriContent
     * @return
     */
    public static LocationMsg toLocationMsg(String oriContent) {
        return LocationMsg.valueOf(StringEscapeUtils.unescapeHtml4(oriContent).replace("<br/>", "").replace("\t", ""));
    }

    /**
     * 转换成名片
     *
     * @param content
     * @return
     */
    public static Card toCard(String content) {
        return Card.valueOf(StringEscapeUtils.unescapeHtml4(content).replace("<br/>", "").replace("\t", ""));
    }

}
